package demo;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 流演示
 *
 * @author dingwen
 * @date 2022/03/24
 */
public class StreamDemo {
    public static void main(String[] args) {

        // 单列集合 collection
        List<String> stringList = Arrays.asList("a","b");
        Stream<String> stream = stringList.stream();

        // 多列集合
        Map<String,String> stringMap = new HashMap<>(2);
        stringMap.put("k1","v1");
        stringMap.put("k2","v2");

        Set<Map.Entry<String, String>> entries = stringMap.entrySet();
        Stream<Map.Entry<String, String>> stream1 = entries.stream();


        // 数组
        Stream<String> stream2 = Arrays.stream(new String[3]) ;


        // Stream
        Stream<Integer> integerStream = Stream.of(12);


        // 收集
        List<String> collect = stringList.stream()
                .map(str -> str.concat("&"))
                .collect(Collectors.toList());


        Map<String, String> collect1 = stringList.stream()
                .collect(Collectors.toMap(k -> k.concat("k"),v -> v.concat("v") ));


    }
}
